<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html>
<input type="hidden" name="id" id="id" value="${id}">
<table style="width: 100%;" class="listtable">
    <tr>
        <td class="">location:&nbsp;</td>
        <td class="tr_right">
            <input name="location" value="${location}" maxlength="200"  class="easyui-validatebox" data-options="required:true,missingMessage:'请输入location'"/>
        </td>
    </tr>
    <tr>
        <td class="">ap:&nbsp;</td>
        <td class="tr_right">
            <input name="ap" value="${ap}" maxlength="200"  class="easyui-validatebox" data-options="required:true,missingMessage:'请输入ap'"/>
        </td>
    </tr>
    <tr>
        <td class="">createTime:&nbsp;</td>
        <td class="tr_right">
            <input name="createTime" value="${createTime}" maxlength="200"  class="easyui-validatebox" data-options="required:true,missingMessage:'请输入createTime'"/>
        </td>
    </tr>
    <tr>
        <td class="">createUser:&nbsp;</td>
        <td class="tr_right">
            <input name="createUser" value="${createUser}" maxlength="200"  class="easyui-validatebox" data-options="required:true,missingMessage:'请输入createUser'"/>
        </td>
    </tr>
    <tr>
        <td class="">updateTime:&nbsp;</td>
        <td class="tr_right">
            <input name="updateTime" value="${updateTime}" maxlength="200"  class="easyui-validatebox" data-options="required:true,missingMessage:'请输入updateTime'"/>
        </td>
    </tr>
    <tr>
        <td class="">updateUser:&nbsp;</td>
        <td class="tr_right">
            <input name="updateUser" value="${updateUser}" maxlength="200"  class="easyui-validatebox" data-options="required:true,missingMessage:'请输入updateUser'"/>
        </td>
    </tr>
</table>
<script type="text/javascript"> 
	$(function(){ 
	    $('#select_type').combobox({
	        url:'${pageContext.request.contextPath}/roomTypeAction!getTypeSelectData.action',
	        valueField:'id',
	        textField:'name',
	        editable:false,
	        onChange:function(newValue,oldValue){
	        	$.ajax({
	                url: '${pageContext.request.contextPath}/roomTypeAction!getTypeValue.action',
	                dataType: 'json',
	                data: {id: newValue},
	                success: function (data) {
	                	if(data.type==1){
	                		$("#addbed").show();
	                		$("#addbed2").show();
	                	}else{
	                		$("#addbed").hide();
	                		$("#addbed2").hide();
	                	}
	                }
	            });
	        }
	    });
	});
	$(function(){ 
	    $('#select_reqioninfo').combobox({
	        url:'${pageContext.request.contextPath}/regionInfoAction!getRegionInfoSelectData.action',
	        valueField:'id',
	        textField:'name',
	        editable:false
	    });
	});
	$(function(){ 
	    $('#select_deckinfo').combobox({
	        url:'${pageContext.request.contextPath}/deckInfoAction!getDeckInfoSelectData.action',
	        valueField:'id',
	        textField:'name',
	        editable:false
	    });

	});
	
	$(function(){ 
		var myid = $("#id").val();
		if(myid==0||myid=='')return;
		$.ajax({
			 url: '${pageContext.request.contextPath}/roomAction!getBedInfoList.action',
			 dataType: 'json',
			 data: {id: myid},
			 success: function (data) {
			 	for (var i = 0; i < data.length; i++) {
			 	   var html = [];
			 		html.push('<tr id="mytr2">');
			 		html.push('<td style="text-align: center;" name="nomber">'+(i+1)+'</td>');
			 		html.push('<td style="text-align: center;" name="myval"><input type="text" name="bedNos" value="'+data[i].bedNo+'" size="3"><input type="hidden" name="bedNoids" value="'+data[i].id+'"></td>');
			 		html.push('<td style="text-align: center;" name="oper" onclick="delLine(this,\''+data[i].id+'\');"><a href="javascript:void(0);"><b>删除</b></a></td>');
			 		html.push('</tr>');
			 		$("#mytable").append(html.join(""));
			 	}
			 }
		});
	});
	
	function addLine(){
		var count = 1;
		$('#mytable tr td').each(function(){
			if($(this).attr("name")=="nomber"){
				$(this).html(count);
				count++;
			}
		});
		var html = [];
		html.push('<tr id="mytr2">');
		html.push('<td style="text-align: center;" name="nomber">'+count+'</td>');
		html.push('<td style="text-align: center;" name="myval"><input type="text" name="bedNos" value="" size="3"><input type="hidden" name="bedNoids" value=""></td>');
		html.push('<td style="text-align: center;" name="oper" onclick="delLine(this,0);"><a href="javascript:void(0);"><b>删除</b></a></td>');
		html.push('</tr>');
		$("#mytable").append(html.join(""));
	}
	function delLine(obj,did){
		if(id==0){
			$(obj).parent().remove();
			var count = 1;
			$('#mytable tr td').each(function(){
				if($(this).attr("name")=="nomber"){
					$(this).html(count);
					count++;
				}
			});
			$.messager.show({
                title: '提示',
                msg: '删除成功'
            });
		}else{
			$.ajax({
	            url: '${pageContext.request.contextPath}/roomAction!deleteBed.action',
	            dataType: 'json',
	            data: {id: did},
	            success: function (data) {
	            	if(data.returnFlag){
						$(obj).parent().remove();
						var count = 1;
						$('#mytable tr td').each(function(){
							if($(this).attr("name")=="nomber"){
								$(this).html(count);
								count++;
							}
						});
	            	}
	           		$.messager.show({
	                    title: '提示',
	                    msg: data.returnMsg
	                });
	            }
	        });
		}
	} 
	function subcheck(){
		var count = 0;
		$('#mytable tr td input[name=bedNos]').each(function(){
			if($(this).val()==''){
				count++;
			}
		});
		if(count>0){
			return false;
		}else{
			return true;
		}
	}
</script>